home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-08-27 | 1.6 KB | 52 lines | [TEXT/MMCC] |
- // ===========================================================================
- // CMyListBox.h ©1994 Jan Bruyndonckx All rights reserved.
- // v1.0 18/6/94
- //
- // A hierarchical demo listbox
- //
- // ===========================================================================
-
- #include <string.h>
- #include "CMyHierListBox.h"
-
- //----------------------------------------------------------------------------
-
- CMyHierListBox* CMyHierListBox::CreateFromStream (LStream *inStream)
- {
- return (new CMyHierListBox(inStream));
- }
-
- CMyHierListBox::CMyHierListBox (LStream *inStream) : CTwistDownListBox (inStream)
- { Cell cell = { -1, 0 } ;
-
- ExpandElement (cell) ;
- }
-
- //----------------------------------------------------------------------------
-
- static StringPtr myElements[] = {
- "\pOne", "\pTwo", "\pThree", "\pFour", "\pFive" } ;
-
- void CMyHierListBox::ExpandElement (const Cell theCell)
- { short num = sizeof (myElements)/sizeof(StringPtr),
- i,
- indent = 0;
- Cell cell = {0, 0} ;
- Byte buffer[100] ;
- TwistDownRecPtr thisTwist = (TwistDownRecPtr) GetCellPtr (theCell) ;
- TwistDownRecPtr anElement = (TwistDownRecPtr) buffer ;
-
- if (thisTwist) indent = thisTwist->indent + 1 ;
-
- ::LAddRow (num, theCell.v+1, mMacListH) ;
-
- for (cell.v = theCell.v+1, i = 0 ; i < num ; i++, cell.v++)
- { anElement->indent = indent ;
- anElement->flags = 0x01 ; // has sublist
- ::memcpy (anElement->data, myElements[i]+1, *myElements[i]) ;
- ::LSetCell (anElement, sizeof (TwistDownRec) - 2 + *myElements[i], cell, mMacListH) ;
- }
- }
-
- //----------------------------------------------------------------------------
-